home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2292 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.0 KB

  1. Path: norconnect.no!not-for-mail
  2. From: kenneth@norconnect.no (Kenneth C. Nilsen)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Removing a patch -A POSSIBLE SOULTION
  5. Date: 30 Jan 1996 00:35:57 +0100
  6. Organization: NorConnect Internet Services AS
  7. Message-ID: <2650.6603T32T2733@norconnect.no>
  8. References: <1996Jan29.141204.23597@ludens>
  9. NNTP-Posting-Host: norconnect.no
  10. X-Newsreader: THOR 2.21 (Amiga;SOUP)
  11.  
  12. >PatchMan:    addq    #1,UseCount    ;how many tasks using this patch?
  13. [...]
  14.  
  15. >Good for a discussion, isn't it? Any thougths?
  16.  
  17. Hi.
  18.  
  19. It will only disallow the patch to be removed while it is in use. It will not
  20. be safe when another program patches the same vector and calling your
  21. routine and you remove the patch:
  22.  
  23.   Your patch -> original function
  24.  
  25. This is ok, now you can remove your patch (-> = calls)
  26.  
  27. The other patch installs itself:
  28.  
  29.   2. Patch -> Your patch -> original function
  30.  
  31.                 /\
  32.                  |
  33.               Vector not in use -> remove (according to your routine)
  34.  
  35. Use vector: 2.Patch -> ??? = guru/hangup (most likely)
  36.  
  37. Your patch keeps the pointer to the original function. When the new patch is
  38. installed it gets the pointer to *your* routine from SetFunction(). If you
  39. remove your patch the new patch will jump into unsafe memory/code since your
  40. routine don't exists anymore.
  41.  
  42. Your patch need something like this:
  43.  
  44. Not in use -> Forbid() -> Remove -> Compare new pointer ->
  45.  
  46. Is it the same as the pointer to your code when you installed your patch?
  47.     no  -> reinstall/enable() and wait/retry/prompt
  48.     yes -> remove/enable()
  49.  
  50. That means if a program has installed a patch after your patch on the same
  51. vector you cannot remove it before the latest patch has removed itself cause:
  52.  
  53. If another patch is installed after yours, the SetFunction() will return a
  54. pointer to this function. If not it should be the same as the pointer as to
  55. your routine when first installing your patch.
  56.  
  57.  
  58. Pseduo:
  59.  
  60.     -> Pointer to MyRoutine
  61.         -> Vector
  62.         -> Library
  63.         Call SetFunction()
  64.         Pointer -> OldFunc
  65.  
  66. [bla bla]
  67.  
  68. Remove:
  69.  
  70.         Forbid()
  71.         -> Orginal pointer
  72.         -> Vector
  73.         -> Library
  74.         Call SetFunction()
  75.         Pointer -> ThisFunc
  76.         Compare ThisFunc with MyRoutine
  77.         if = then continue, else stay patched (reinstall with SetFunction())
  78.         Permit()
  79.  
  80. Reinstall: (stay patched)
  81.  
  82.         ->ThisFunc
  83.         ->Vector
  84.         ->Library
  85.         Call SetFunction()
  86.         ...
  87.         Permit()
  88.         Prompt requester "Can't remove: vector is patched by another program"
  89.  
  90. When installing patches:
  91.  
  92. Patch 1 -> 2 -> 3 -> 4 etc.
  93.  
  94. Must be removed like this:
  95.  
  96. Patch 4 -> 3 -> 2 -> 1
  97.  
  98. Since the patch installed last is depended on the old patch/routine before.
  99.  
  100. Again: you cannot remove patch no. 2 before patch 3 and 4 are removed.
  101.  
  102. Hope this clears things up a little :-)
  103.  
  104.  
  105. ---
  106. CREATIVE LINKS                       __     Kenneth C. Nilsen
  107. http://www.norconnect.no/~kenneth   /_/\    e-mail: kenneth@norconnect.no
  108. "Everything you want"               \_\/    Software & MultiMedia developer
  109.